﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
 
<title>jb-aptech毕业设计项目</TITLE>
<meta name="renderer" content="ie-comp">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="../../css/style.css" rel="stylesheet" type="text/css">
	<script src="../../js/vue.js"></script>
	<script src="../../js/jquery/jquery-1.5.2.min.js"></script>
<script src="script/common.js"></script>
<script src="script/validate.js"></script>
</head>
  	<script type="text/javascript">
  		function myAdd(){
  		
  			document.sysUserForm.submit();
  		}
  	</script>
  <body>
  <div id="app">
    <div class="page_title">权限管理 > 用户管理 > 系统用户</div>
    <form name="sysUserForm" method="post" action="/CRM/sysUser.do">
    	<input type="hidden" name="method" value="editUser">
    	<div class="button_bar">
	   		<button class="common_button" onclick="help('');">帮助</button>
	   		<button class="common_button" onclick="back();">返回</button>
			<button class="common_button" @click="up" type="button">保存</button>
	   	</div>
	   	<table class="query_form_table" v-for="s in sum">
	   		<tr>
	   			<th>编号</th>
				<td v-text="s.usr_id" id="bh"></td>
	   			<th>用户名</th>
	   			<td>
	   				<input type="text" name="sysUser.usrName" size="20" id="yhm" :value="s.usr_name">
	   			</td>
	   		</tr>
	   		<tr>
	   			<th>密码</th>
	   			<td><br><br><input type="text" name="sysUser.usrPassword" id="mm" :value="s.usr_password">
	   			<br><br></td>
	   			<th>角色</th>
	   			<td>
	   				
	   				
	   					管理员

					<select id="js">
						<option v-if="s.role_name==''"  value="s.usr_role_id" v-text="s.role_name" selected="selected"></option>
						<option v-if="s.role_name==''" value="0" selected="selected">未指派</option>

						<option value="1">管理员</option>
						<option value="3">销售主管</option>
						<option value="4">客户经理</option>
						<option value="5">高管</option>
						<option value="9">销售员</option>
						<option value="0">未分配</option></select>
	   			</td>
	   		</tr>
	   		<tr>
	   			<th>状态</th>
	   			<td>

					<select id="zt">
						<option v-if="s.role_name==1" value="" value="1" selected="selected">正常</option>
						<option v-if="s.role_name==2" value="" value="2" selected="selected">禁用</option>
						<option value="1">正常</option>
						<option value="2">禁用</option>
					</select>
	   			</td>
	   		</tr>
	   	</table>
    </form>
  </div>
  </body>
<script>
	const  app=new Vue({
		el:"#app",
		data:{
			sum:[],
			sums:{
				usr_id:"",
			},
		},methods:{
			load(){
				$.getJSON("/SysUser/queryPages",this.sums,json=>{
					this.pageInfo=json.data.pageInfo;
					this.sum=json.data.pageInfo.list;
				});
			},
			up(){
				let bh = $("#bh").text();
				let yhm = $("#yhm").val();
				let mm = $("#mm").val();
				let js = $("#js").val()
				let zt = $("#zt").val();
				$.post("/SysUser/update", {"usr_id":bh,"usr_name":yhm,"usr_password":mm,"usr_role_id":js,"usr_flag":zt}, json => {
					if (json.message == "OK") {
						alert("保存成功");
						location.href = "list.html";
					} else {
						alert("保存失败");
						location.href = "list.html";
					}
				})
			}
		},mounted(){
			let ser=new URLSearchParams(location.search).get("usr_id");
			this.sums.usr_id=ser;

			this.load();
		}
	});
</script>
</html>
